package com.zgx.webpoolsandroid

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.webkit.WebView
import kotlinx.android.synthetic.main.activity_main.*

class SecondActivity : AppCompatActivity() {

    private var mWebView: WebView? = null;

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val start = System.currentTimeMillis()

        mWebView = WebPools.getInstance().acquireWebView(this);
        layout_web.addView(mWebView, 1500, 500)
        //https://blog.csdn.net/huangpin815/article/details/79283280?utm_source=blogxgwz1
        mWebView?.loadUrl("http://img5.imgtn.bdimg.com/it/u=3614534200,1549941437&fm=26&gp=0.jpg")

        tv_txt.setText("复用webview初始化时间 ：" + (System.currentTimeMillis() - start))
    }

    override fun onDestroy() {
        super.onDestroy()
        WebPools.getInstance().recycle(mWebView)
    }

}